<template>
	<view class="index">
		<!-- 顶部导航 -->
		<index-tabbar :swiperIndexInfo="swiperIndexInfo" :indexArticleInfos="indexArticleInfos"></index-tabbar>
		<!-- 主体 -->
		<index-content @swiperIndex="swiperIndex" :indexArticleInfos="indexArticleInfos"></index-content>

	</view>
</template>

<script>
	import indexTabbar from './indexTabbar/indexTabbar.vue'
	import indexContent from './indexContent/indexContent.vue'
	import cloudApi from '../../common/cloudApi.js'
	import getcalendar from '../../common/calendar.js'
	export default {
		components: {
			indexTabbar,
			indexContent
		},
		data() {
			return {
				swiperIndexInfo:'',
				indexArticleInfos:[]
			}
		},
		methods: {
			//轮播下标索引
			swiperIndex(item){
				this.swiperIndexInfo=item
			},
			//时间日期
			getTime(){
				// const getDateCalendar = getcalendar.calendar.solar2lunar(2022,'01',18);
				const getDateCalendar = getcalendar.calendar.solar2lunar(new Date());
				console.log("时间日期");
				console.log(getDateCalendar);
				//调用名为indexArticle的云函数，获取数据
				cloudApi.call({
					name: "indexArticle",
					data:{
						typeName:'setData',
						date:getDateCalendar.date,
						//几号
						cDay:getDateCalendar.cDay,
						//星期几
						ncWeek:getDateCalendar.ncWeek,
						//农历几月
						IMonthCn:getDateCalendar.IMonthCn,
						//农历几号
						IDayCn:getDateCalendar.IDayCn,
						//文章
						textArticle:'',
						//收藏
						love:0,
						//评论
						comments:0
					},
					success: (res) => {
						console.log(res.result.data);
						this.indexArticleInfos=res.result.data.reverse();
					}
				})
			},
			// indexArticleInfo(){
			// 	//调用名为indexArticle的云函数，获取数据
			// 	cloudApi.call({
			// 		name: "indexArticle",
			// 		data:{
			// 			typeName:'getData',
			// 			// date:getDateCalendar.date
			// 		},
			// 		success: (res) => {
			// 			console.log(res.result.data);
			// 			this.indexArticleInfos=res.result.data
			// 		}
			// 	})
			// }
		},
		async onLoad() {
			//将当天的日期存起来
			this.getTime();
			//获取首页数据
			// this.indexArticleInfo();
		}
	}
</script>

<style lang="scss">
	
</style>
